/**
 * Project Name:YCApiServer-Api
 * File Name:AccompanimentService.java
 * Package Name:com.yc.music.service.service103
 * Date:2016年5月12日下午3:25:24
 * Copyright (c) 2016 
 *
 */
package com.yc.music.service.service103;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.yc.music.common.context.YcContext;
import com.yc.music.common.util.RoomUtil;
import com.yc.music.mapper.cache.AccompanimentCategoryCacheMapper;
import com.yc.music.mapper.cache.HotTempCacheMapper;
import com.yc.music.model.accompaniment.TempHotVo;
import com.yc.music.model.accompanimentcategory.AccompanimentCategoryVo;

/**
 * 
 * ClassName: AccompanimentCategoryService <br/>
 * Function: 伴奏分类. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年8月8日 下午7:13:38 <br/>
 *
 * @author qinhaiguan
 */
@Service
public class AccompanimentCategoryService {


	@Value("${Pic_QiLiu}")
	private String pIC_QiLiu;
	
	@Value("${Audio_QiLiu}")
	private String audio_QiLiu;
	
	@Autowired
	private AccompanimentCategoryCacheMapper accompanimentCategoryCacheMapper;
	
	@Autowired
	private HotTempCacheMapper hotTempCacheMapper;
	
	
	
	public Map<String, Object> getAccompanimentCategoryList(Integer page, Map<String, Object> result) throws Exception {
		//每页显示12个伴奏
		int start = 0, size = 12;
		if (page !=null && page > 1) {
			start = (page - 1) * 10;
		}
		List<AccompanimentCategoryVo> list=accompanimentCategoryCacheMapper.getAccompanimentCategoryListPage(start, size);
		TempHotVo hotVo=hotTempCacheMapper.getTempHotById();
		if(hotVo!=null) {
			hotVo.setPic(RoomUtil.jointDomain(hotVo.getPic(),pIC_QiLiu));
			hotVo.setMp3(RoomUtil.jointDomain(hotVo.getMp3(),audio_QiLiu));
		}
		if(list!=null) {
			for(AccompanimentCategoryVo vo:list) {
				vo.setCategorypic(RoomUtil.jointDomain(vo.getCategorypic(),pIC_QiLiu));
			}
		}
		Map<String, Object> map=new HashMap<String,Object>();
		map.put("list", list);
		//只有第一页返回清唱的数据
		if (page==1) {
			map.put("simplesing", hotVo);
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, map);
//		result.put("simple", hotVo);
		return result;
	}
	
	
	public Map<String, Object> getAccompanimentCategoryList22(Map<String, Object> result) throws Exception {
		Map<String, Object> map=new HashMap<String, Object>();
		//获取清唱伴奏信息
		TempHotVo hotVo=hotTempCacheMapper.getTempHotById();
		if(hotVo!=null) {
			hotVo.setPic(RoomUtil.jointDomain(hotVo.getPic(),pIC_QiLiu));
			hotVo.setMp3(RoomUtil.jointDomain(hotVo.getMp3(),audio_QiLiu));
		}		
		//清唱的信息
		map.put("simplesing", hotVo);
		
		List<AccompanimentCategoryVo> list=accompanimentCategoryCacheMapper.getAccompanimentCategoryListPage22();
		if(list!=null) {
			for(AccompanimentCategoryVo vo:list) {
				vo.setCategorypic(RoomUtil.jointDomain(vo.getCategorypic(),pIC_QiLiu));
			}
		}
		
		map.put("list", list);
		
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, map);
		return result;
	}
	
}
